

import 'package:bt_tool/basic/bt_common_define.dart';
import 'package:bt_tool/basic/bt_controller.dart';
import 'package:bt_tool/basic/bt_nav_tool.dart';
import 'package:bt_tool/widget/bt_check_box.dart';
import 'package:bt_tool/widget/bt_widget.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_demo/tools/translate/controller/translate_config_controller.dart';
import 'package:flutter_demo/tools/translate/translate_define.dart';
import 'package:get/get.dart';

class TranslateConfigPage extends BTStatefulWidget{

  const TranslateConfigPage({super.key,super.routerConfig});

  @override
  State<StatefulWidget> createState() {
    return TranslateConfigState();
  }

}

class TranslateConfigState extends BTState<TranslateConfigPage>{

  final TranslateConfigController controller = TranslateConfigController();

  @override
  BTController btCtrl() {
    return controller;
  }

  @override
  Widget build(BuildContext context) {
    if(controller.projectModel == null){
      return Container();
    }
    return Scaffold(
      appBar: BTNavTool.createAppBar(
        title: "翻译配置",
        context: context,
        actionListStr: ["保存"],
        rightPadding: 20,
        actionCallBack: (index){
          controller.saveClick();
        }
      ),
      body: SingleChildScrollView(
        child: Container(
          padding: const EdgeInsets.all(12),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Container(constraints: const BoxConstraints.expand(height: 1),),
              const Text("导出类型"),
              const SizedBox(height: 10,),
              Obx((){
                return Wrap(
                  spacing: 16,
                  runSpacing: 16,
                  children: [
                    BTCheckBox(
                      isSelect: controller.projectModel?.translateExportType.value == TranslateDefaultExportType.ios.iValue,
                      title: "iOS风格",
                      clickCallback: (obj){
                        controller.projectModel?.translateExportType.value = TranslateDefaultExportType.ios.iValue;
                      },
                      normalImg: Image.asset(btPngPath("bt/bt_check_box_nor"),width: 18,height: 18,),
                      selectImg: Image.asset(btPngPath("bt/bt_check_box_sel"),width: 18,height: 18,),
                    ),

                    BTCheckBox(
                      isSelect: controller.projectModel?.translateExportType.value == TranslateDefaultExportType.json.iValue,
                      title: "JSON风格",
                      clickCallback: (obj){
                        controller.projectModel?.translateExportType.value = TranslateDefaultExportType.json.iValue;
                      },
                      normalImg: Image.asset(btPngPath("bt/bt_check_box_nor"),width: 18,height: 18,),
                      selectImg: Image.asset(btPngPath("bt/bt_check_box_sel"),width: 18,height: 18,),
                    )
                  ],
                );
              }),
              const SizedBox(height: 10,),
              const Text("母语"),
              const SizedBox(height: 10,),
              Obx((){
                List<Widget> listWidget = [];
                for(var model in controller.motherLanguageList){
                  var widget = BTCheckBox(
                    isSelect: model.isSelect,
                    title: model.title,
                    clickCallback: (obj){
                      controller.resetMotherLanguageData();
                      model.isSelect = !model.isSelect;
                      controller.motherLanguageList.refresh();
                    },
                    normalImg: Image.asset(btPngPath("bt/bt_check_box_nor"),width: 18,height: 18,),
                    selectImg: Image.asset(btPngPath("bt/bt_check_box_sel"),width: 18,height: 18,),
                  );
                  listWidget.add(widget);
                }

                return Wrap(
                  spacing: 16,
                  runSpacing: 16,
                  children: listWidget,
                );
              }),
              const SizedBox(height: 30,),
              const Text("目标语言"),
              const SizedBox(height: 10,),
              Obx((){
                List<Widget> listWidget = [];
                for(var model in controller.translateTargetList){
                  var widget = Row(
                    mainAxisSize: MainAxisSize.min,
                    children: [
                      BTCheckBox(
                        isSelect: model.isSelect,
                        title: model.title,
                        clickCallback: (obj){
                          model.isSelect = !model.isSelect;
                          controller.translateTargetList.refresh();
                        },
                        normalImg: Image.asset(btPngPath("bt/bt_check_box_nor"),width: 18,height: 18,),
                        selectImg: Image.asset(btPngPath("bt/bt_check_box_sel"),width: 18,height: 18,),
                      )
                    ],
                  );
                  listWidget.add(widget);
                }

                return Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  mainAxisSize: MainAxisSize.min,
                  spacing: 16,
                  children: listWidget,
                );
              }),

            ],
          ),
        ),
      ),
    );
  }



}
